package mobNodesBusiness;

import impl.TestServerBusinessImpl;
import models.HttpResponse;
import models.MyConfig;
import models.ReturnJson;
import tools.Http;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * Created by yangxianming on 2023/5/5.
 */
public class MobNodesLogManger implements TestServerBusinessImpl {
    @Override
    public String doIt(HttpServletRequest request, MyConfig myConfig) {
        ReturnJson returnJson = new ReturnJson();
        String action = request.getParameter("action");
        String nodeAddress = request.getParameter("node");
        Http http = new Http();
        if (Objects.equals(nodeAddress, null) || Objects.equals(nodeAddress, "")){
            //补上一个默认值
            nodeAddress = "123.60.96.211:1955";
        }
        String url = "http://" + nodeAddress + "/mobLog/mobLogManager";

        if (Objects.equals(action, "getLogDateList")){

            HttpResponse hr = http.sendRequest("get", null, url, "action=getLogDateList");
            return hr.getResponseResult();
        }

        if (Objects.equals(action, "getDateLog")){
            String date = request.getParameter("date");
            HttpResponse hr = http.sendRequest("get", null, url, "action=getDateLog&date="+date);
            return hr.getResponseResult();
        }

        return null;
    }
}
